#include "label.h"



Label::Label(void)
{
  uLabel = 0;
  bLabelComplete = 0;
  uCurrentLabelBitPosition = 0;

  std::cout << "Label Created!" << std::endl;
}

Label::~Label(void)
{
  std::cout << "Label Destroyed!" << std::endl;
}

void Label::PrintLabel(void)
{
  std::cout << "Label: " << uLabel << std::cout;
}

void Label::WriteCurrentAddressBit(bool addressBit)
{

  /* only set a 1 if passing a 1 */
  if(addressBit)
  {
    /* set specific bit position with a 1 */
    uLabel |= (LABELSHIFTSTART >> uCurrentLabelBitPosition);
  }

  /* increment bit position Regardless of a 1 or 0 input if within range */
  if(uCurrentLabelBitPosition < (sizeof(uLabel) * 4))
  {
    uCurrentLabelBitPosition++;
  }
  else
  {
    bLabelComplete = 1;
  }
}

void Label::ResetLabelToBeginning(void)
{
  /* reset label */
  /* NOTE: It is still possible that a label position = 0 */
  uLabel = 0;

  /* reset label complete flag */
  bLabelComplete = 0;
  
  /* restart counting label bit positions */
  uCurrentLabelBitPosition = 0;
}

bool Label::ReadLabelBit(unsigned int labeBitPosition)
{
  return ((uLabel & (LABELSHIFTSTART >> labeBitPosition)) > 0);
}

unsigned int Label::ReadCurrentLabel(void)
{
  return uLabel;
}

unsigned int Label::ReadCurrentLabelBitPosition(void)
{
  return uCurrentLabelBitPosition;
}
